package com.example.takeaway.websocket;


import com.alibaba.fastjson.JSON;
import com.example.takeaway.websocket.message.AbstractMessage;

import javax.websocket.EncodeException;
import javax.websocket.Encoder;
import javax.websocket.EndpointConfig;

/**
 * @author 邢晨旭
 * {@code @date} 2023/10/26
 */
public class WsMessageEncoder implements Encoder.Text<AbstractMessage> {

    @Override
    public String encode(AbstractMessage abstractMessage) throws EncodeException {
        return JSON.toJSONString(abstractMessage);
    }

    @Override
    public void init(EndpointConfig endpointConfig) {

    }

    @Override
    public void destroy() {

    }
}
